//=============================================================================
// TazerFire.
//=============================================================================
class TazerFire extends WeaponFire;

var Actor Other;
var EnyaraPlayerController EC;
var Pawn SP;
var Controller SPC;
var bool bIsStunned;
var int iStunTimeRemaining;

function MeleeTargetting()
{
  local vector HitLoc, HitNorm, X, Y, Z, StartTrace, EndTrace;
  local rotator Aim;

  // Get vectors for where the player is aiming on each axis
  GetAxes(Instigator.GetViewRotation(), X, Y, Z);
  // Calculate starting location
  StartTrace = Instigator.Location + Instigator.EyePosition() + X*Instigator.CollisionRadius;
  Aim = AdjustAim(StartTrace, AimError);
  // Using an arbitrary range of 100 UUs
  X = Vector(Aim);
  EndTrace = StartTrace + 100 * X;
  // See if we hit any thing
  Other = Trace(HitLoc, HitNorm, EndTrace, StartTrace, true);

  if (Other != None)
  {
    if (Pawn(Other) != none && Pawn(Other).IsHumanControlled()) {
       EC = EnyaraPlayerController(Pawn(Other).Controller);
      // Level.GetLocalPlayerController().clientMessage("You just got stunned by bot");
       if (EC != none) {
           EC.GotoState('Stunned');
       }
    }
  }
}

event ModeDoFire()
{
  if (!AllowFire())
     return;

  MeleeTargetting();
}

defaultproperties
{
     PreFireAnim="PreFire"
     FireAnim="Fire"
     FireLoopAnim="FireLoop"
     FireEndAnim="FireEnd"
     ReloadAnim="Reload"
     NoAmmoSound=ProceduralSound'WeaponSounds.PReload5.P1Reload5'
     FireRate=0.500000
     AmmoClass=Class'XWeapons.LinkAmmo'
     AmmoPerFire=1
     ShakeRotMag=(Z=60.000000)
     ShakeRotRate=(Z=4000.000000)
     ShakeRotTime=6.000000
     ShakeOffsetMag=(Y=1.000000,Z=1.000000)
     ShakeOffsetRate=(X=1000.000000,Y=1000.000000,Z=1000.000000)
     ShakeOffsetTime=3.000000
     BotRefireRate=0.990000
     WarnTargetPct=0.200000
     FlashEmitterClass=Class'XEffects.LinkMuzFlashBeam1st'
}
